<template>
    <div class="game-body">
      <MenuView v-if="$store.state.router.router_name == 'menu'"/>
      <PkIndexViewVue v-else-if="$store.state.router.router_name == 'pk'"/>
      <RecordIndexViewVue v-else-if="$store.state.router.router_name == 'record'"/>
      <RankListIndexViewVue v-else-if="$store.state.router.router_name == 'ranklist'"/>
      <RecordContentViewVue v-else-if="$store.state.router.router_name == 'record_content'"/>
      <UserBotIndexViewVue v-else-if="$store.state.router.router_name == 'user_bot'"/>
    </div>

</template>


<script>
import { useStore } from 'vuex' 
import MenuView from "./views/MenuView.vue"
import RankListIndexViewVue from "./views/ranklist/RankListIndexView.vue"
import PkIndexViewVue from "./views/pk/PkIndexView.vue"
import RecordIndexViewVue from "./views/record/RecordIndexView.vue"
import RecordContentViewVue from "./views/record/RecordContentView.vue"
import UserBotIndexViewVue from "./views/user/bots/UserBotIndexView.vue"
/* import $ from 'jquery' */

export default{
  components: {
    MenuView,
    PkIndexViewVue,
    RecordContentViewVue,
    RecordIndexViewVue,
    UserBotIndexViewVue,
    RankListIndexViewVue,
  },

   setup() {
    const store = useStore();
    const jwt_token = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIwZDdlM2RlMmE0Yjg0OWZlOTY5ZTg0ZGQ1NDAwNzIxYyIsInN1YiI6IjIiLCJpc3MiOiJzZyIsImlhdCI6MTY2NzcyNjYwNiwiZXhwIjoxNjY4OTM2MjA2fQ.zLHJXAR2MNp4Uhxe1ES76kLpdIlw6bON0MO0CSa68Jo"; // 登入之后取得token，在未到期之前可以自动登入
        if (jwt_token) {
            store.commit("updateToken", jwt_token); // 调用mutations中的updateToken函数
            store.dispatch("getinfo", { // 从云端获取信息, 即令牌还未过期的话
                success() {
                    store.commit("updatePullingInfo", false);
                },

                error() {
                    store.commit("updatePullingInfo", false); // 若是令牌过期将登入业面展示出来
                }

            })
        } else {
           store.commit("updatePullingInfo", false);// 若是本地没有token的话将登入业面展示出来
        }
  } 


}
</script>


<style scoped>
body {
  margin: 0;
}
div.game-body{
background: url("./assets/images/download.jpg") no-repeat;
height:100%;
width:100%;
overflow: hidden;
background-size:cover;
}

div.window {
  width: 100vw;
  height: 100vh;
}
</style>
